<?php
namespace app\queue\controller;

use app\BaseController;
use think\facade\View;
use think\facade\Cache;
use think\facade\Queue;
use think\queue\Job;
use think\facade\Db;
use think\facade\Log;
use app\job\ApiDoc as  ApiDoc;

class TestApi extends BaseController
{

  public function get_data($data=''){
    $data = input();
    $data = Array
    (
        'appkey' => '24621156',
        'secretKey' => '0bb03f8580bee64c5a03e50a67f3e222',
        'page_size' => '100',
        'query_type' => '2',
        'jump_type' => '1',
        'member_type' => '',        
        'tk_status' => '',
        'order_scene' => '1',
        'position_index' => '',
        'page_no' => '1',
        'branch_id' => '2',
        'queName' => 'orderTb',
        't_name' => 'vi_lbx_125115330_tbk_orders_202003'
    );
    p($data);
    $res = $this->http_post('http://cms.928853988.cn/queue/orderYue',$data);
    dump($res);
    p($res);
  }

  /**
   * POST 请求
   * @param string $url
   * @param array $param
   * @param boolean $post_file 是否文件上传
   * @return string content
   */
  public function http_post($url, $param, $post_file = false)
  {
      $oCurl = curl_init();
      if (stripos($url, "https://") !== FALSE) {
          curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
          curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
          curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
      }
      if (is_string($param) || $post_file) {
          $strPOST = $param;
      } else {
          $aPOST = array();
          foreach ($param as $key => $val) {
              //$val = strval($val);
              $aPOST[] = $key . "=" .$val;
          }
          $strPOST = join("&", $aPOST);
      }
      curl_setopt($oCurl, CURLOPT_URL, $url);
      curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($oCurl, CURLOPT_POST, true);
      curl_setopt($oCurl, CURLOPT_POSTFIELDS, $strPOST);
      $sContent = curl_exec($oCurl);
      return $sContent;
      $aStatus  = curl_getinfo($oCurl);
      curl_close($oCurl);
      if (intval($aStatus["http_code"]) == 200){
          return $sContent;
      } else {
          return false;
      }
  }

   
}
